<!doctype html>
<html class="no-js" lang="zxx">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>易购 - 书籍</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="assets/img/icon/favicon.png">

    <!-- CSS here -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css">
    <link rel="stylesheet" href="assets/css/slicknav.css">
    <link rel="stylesheet" href="assets/css/animate.min.css">
    <link rel="stylesheet" href="assets/css/price_rangs.css">
    <link rel="stylesheet" href="assets/css/magnific-popup.css">
    <link rel="stylesheet" href="assets/css/fontawesome-all.min.css">
    <link rel="stylesheet" href="assets/css/themify-icons.css">
    <link rel="stylesheet" href="assets/css/slick.css">
    <link rel="stylesheet" href="assets/css/nice-select.css">
    <link rel="stylesheet" href="assets/css/style.css">

    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
</head>
<body>
<div id="app">
    <header>
        <div class="header-area">
         <div class="main-header ">
             <div class="header-top ">
                <div class="container">
                   <div class="row">
                    <div class="col-xl-12">
                        <div class="d-flex justify-content-between align-items-center flex-sm">
                            <div class="header-info-left d-flex align-items-center">
                                <!-- logo -->
                                <div class="logo">
                                    <a href="index.html"><img src="assets/img/logo/logo.png" alt=""></a>
                                </div>
                                <!-- Search Box -->
                                <form action="#" class="form-box">
                                    <input type="text" name="Search" placeholder="请输入关键字进行搜索">
                                    <div class="search-icon">
                                        <i class="ti-search"></i>
                                    </div>
                                </form>
                            </div>
                            <div class="header-info-right d-flex align-items-center">
                                <ul>                                   
                                    <li><a href="#">我的订单</a></li>
                                    <li class="shopping-card">
                                        <a href="cart.html"><img src="assets/img/icon/cart.svg" alt=""></a>
                                    </li>
                                    <li v-if="username==null || username==''">
                                        <a href="login.html" class="btn header-btn">登录</a>
                                    </li>
                                    <li v-else>
                                        <a href="center.html">{{username}}</a>
                                        <a @click="logout" style="border-bottom: 1px solid red;margin-left: 10px;cursor: pointer">退出</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="header-bottom  header-sticky">
         <div class="container">
             <div class="row align-items-center">
                <div class="col-xl-12">
                    <!-- logo 2 -->
                    <div class="logo2">
                        <a href="index.html"><img src="assets/img/logo/logo.png" alt=""></a>
                    </div>
                    <!-- 导航 -->
                    <div class="main-menu text-center d-none d-lg-block">
                        <nav>                                                
                            <ul id="navigation">    
                                <li><a href="index.html">Home</a></li>
                                <li><a href="categories.html">Categories</a></li>
                                <li><a href="about.html">About</a></li>
                                <li><a href="#">Pages</a>
                                    <ul class="submenu">
                                        <li><a href="login.html">login</a></li>
                                        <li><a href="cart.html">Cart</a></li>
                                        <li><a href="checkout.html">Checkout</a></li>
                                        <li><a href="book-details.html">book Details</a></li>
                                        <li><a href="blog_details.html">Blog Details</a></li>
                                        <li><a href="elements.html">Element</a></li>
                                    </ul>
                                </li>
                                <li><a href="blog.html">Blog</a></li>
                                <li><a href="contact.html">Contect</a></li>
                            </ul>
                        </nav>
                    </div>
                </div> 
                <!-- Mobile Menu -->
                <div class="col-xl-12">
                    <div class="mobile_menu d-block d-lg-none"></div>
                </div>
            </div>
        </div>                         
    </div>
</div>

</div>
</header>
<main>
    <!--  services-area start-->
    <div class="services-area2">
        <div class="container">
            <div class="row">
                <div class="col-xl-12">
                    <div class="row">
                        <div class="col-xl-12">
                            <!-- Single -->
                            <div class="single-services d-flex align-items-center mb-0">
                                <div class="features-img">
                                    <img width="280px" height="350px" :src="JSON.parse(goods.imgs)[0].url" alt="">
                                </div>
                                <div class="features-caption">
                                    <h3>{{goods.name}}</h3>
                                    <p v-for="brand in brandList" :key="brand.id" v-if="brand.id == goods.brandid">{{brand.name}}</p>
                                    <div class="price">
                                        <span>${{(goods.price/100).toFixed(2)}}</span>
                                    </div>
                                    <div class="review">
                                        <div class="rating">
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star-half-alt"></i>
                                        </div>
                                        <p>({{goods.sales}} 已售)</p>
                                    </div>
                                    <a @click="addCart" class="white-btn mr-10">添加到购物车</a>
                                    <a href="#" class="border-btn share-btn"><i class="fas fa-share-alt"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- services-area End-->
    <!--Books review Start -->
    <section class="our-client section-padding best-selling">
        <div class="container">
            <div class="row">
                <div class="offset-xl-1 col-xl-10">
                    <div class="nav-button f-left">
                        <!--Nav Button  -->
                        <nav>
                            <div class="nav nav-tabs " id="nav-tab" role="tablist">
                                <a class="nav-link active" id="nav-one-tab" data-bs-toggle="tab" href="#nav-one" role="tab" aria-controls="nav-one" aria-selected="true">商品详情</a>
                                <a class="nav-link" id="nav-two-tab" data-bs-toggle="tab" href="#nav-two" role="tab" aria-controls="nav-two" aria-selected="false">售后服务</a>
                                <a class="nav-link" id="nav-three-tab" data-bs-toggle="tab" href="#nav-three" role="tab" aria-controls="nav-three" aria-selected="false">商品评价</a>
                            </div>
                        </nav>
                        <!--End Nav Button  -->
                    </div>
                </div>
            </div>
        </div>
        <div class="container">
            <!-- Nav Card -->
            <div class="tab-content" id="nav-tabContent">
                <div class="tab-pane fade show active" id="nav-one" role="tabpanel" aria-labelledby="nav-one-tab">
                    <!-- Tab 1 -->  
                    <div class="row">
                        <div class="offset-xl-1 col-lg-9">
                            <p v-html="goods.content"></p>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="nav-two" role="tabpanel" aria-labelledby="nav-two-tab">
                    <!-- Tab 2 -->
                    <div class="row">
                        <div class="offset-xl-1 col-lg-9">
                            <p v-html="goods.aftersales"></p>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="nav-three" role="tabpanel" aria-labelledby="nav-three-tab">
                    <!-- Tab 3 -->
                    <div class="row">
                        <div class="offset-xl-1 col-lg-9" v-for="i in 10">
                            <p>{{i}}**** ：2020-12-12</p>
                            <p>非常好</p>
                            <p>
                                <div class="rating" style="color: red">
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                </div>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- Books review End -->
</main>
<footer>
    <div class="footer-wrappper section-bg">
     <div class="footer-area footer-padding">
         <div class="container">
             <div class="row justify-content-between">
                 <div class="col-xl-3 col-lg-5 col-md-4 col-sm-6">
                     <div class="single-footer-caption mb-50">
                         <div class="single-footer-caption mb-30">
                             <!-- logo -->
                             <div class="footer-logo mb-25">
                                 <a href="index.html"><img src="assets/img/logo/logo2_footer.png" alt=""></a>
                             </div>
                             <div class="footer-tittle">
                                 <div class="footer-pera">
                                     <p>Get the breathing space now, and we’ll extend your term at the other end year for go.</p>
                                 </div>
                             </div>
                             <!-- social -->
                             <div class="footer-social">
                                <a href="https://bit.ly/sai4ull"><i class="fab fa-facebook"></i></a>
                                <a href="#"><i class="fab fa-instagram"></i></a>
                                <a href="#"><i class="fab fa-linkedin-in"></i></a>
                                <a href="#"><i class="fab fa-youtube"></i></a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xl-2 col-lg-3 col-md-4 col-sm-5">
                 <div class="single-footer-caption mb-50">
                     <div class="footer-tittle">
                         <h4>Book Category</h4>
                         <ul>  
                             <li><a href="#">History</a></li>
                             <li><a href="#">Horror - Thriller</a></li>
                             <li><a href="#">Love Stories</a></li>
                             <li><a href="#">Science Fiction</a></li>
                             <li><a href="#">Business</a></li>
                         </ul>
                     </div>
                 </div>
             </div>
             <div class="col-xl-2 col-lg-3 col-md-4 col-sm-6">
                 <div class="single-footer-caption mb-50">
                     <div class="footer-tittle">
                         <h4>&nbsp;</h4>
                         <ul>
                            <li><a href="#">Biography</a></li>
                            <li><a href="#">Astrology</a></li>
                            <li><a href="#">Digital Marketing</a></li>
                            <li><a href="#">Software Development</a></li>
                            <li><a href="#">Ecommerce</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6">
             <div class="single-footer-caption mb-50">
                 <div class="footer-tittle">
                     <h4>Site Map</h4>
                     <ul class="mb-20">
                         <li><a href="#">Home</a></li>
                         <li><a href="#">About Us</a></li>
                         <li><a href="#">FAQs</a></li>
                         <li><a href="#">Blog</a></li>
                         <li><a href="#">Contact</a></li>
                     </ul>
                 </div>
             </div>
         </div>
     </div>
 </div> 
</div>
<!-- footer-bottom area -->
<div class="footer-bottom-area">
 <div class="container">
     <div class="footer-border">
         <div class="row d-flex align-items-center">
             <div class="col-xl-12 ">
                 <div class="footer-copy-right text-center">
                     Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart color-danger" aria-hidden="true"></i> by <a href="https://colorlib.com" style="color: black"target="_blank" rel="nofollow noopener">Colorlib</a>

                 </div>
             </div>
         </div>
     </div>
 </div>
</div>
</div>
</footer>
<!-- Scroll Up -->
<div id="back-top" >
    <a title="Go to Top" href="#"> <i class="fas fa-level-up-alt"></i></a>
</div>
</div>
<!-- JS here -->
<!-- Jquery, Popper, Bootstrap -->
<script src="./assets/js/vendor/modernizr-3.5.0.min.js"></script>
<script src="./assets/js/vendor/jquery-1.12.4.min.js"></script>
<script src="./assets/js/popper.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>

<!-- Slick-slider , Owl-Carousel ,slick-nav -->
<script src="./assets/js/owl.carousel.min.js"></script>
<script src="./assets/js/slick.min.js"></script>
<script src="./assets/js/jquery.slicknav.min.js"></script>

<!--wow , counter , waypoint, Nice-select -->
<script src="./assets/js/wow.min.js"></script>
<script src="./assets/js/jquery.magnific-popup.js"></script>
<script src="./assets/js/jquery.nice-select.min.js"></script>
<script src="./assets/js/jquery.counterup.min.js"></script>
<script src="./assets/js/waypoints.min.js"></script>
<script src="./assets/js/price_rangs.js"></script>

<!-- contact js -->
<script src="./assets/js/contact.js"></script>
<script src="./assets/js/jquery.form.js"></script>
<script src="./assets/js/jquery.validate.min.js"></script>
<script src="./assets/js/mail-script.js"></script>
<script src="./assets/js/jquery.ajaxchimp.min.js"></script>

<!--  Plugins, main-Jquery -->	
<script src="./assets/js/plugins.js"></script>
<script src="./assets/js/main.js"></script>
</body>

<script>

    new Vue({
        el:"#app",
        data:{
            goods:{
            },
            brandList:[],
            username:""
        },
        created(){
            this.loadData()
            this.loadBrandList()
        },
        mounted(){
            this.verify()
        },
        methods:{
            loadData(){
                let id = location.search.substring(1).split("=")[1]
                axios.get(`/goods/findGoodsById/${id}`).then(({data})=>{
                  this.goods = data
                })
            },
            loadBrandList() {
                axios.get(`/brand/findall`).then(({data}) => {
                    this.brandList = data.data
                })
            },
            verify(){
                axios.get(`/verify`).then(({data})=>{
                    this.username = data
                })
            },
            addCart(){
                // 校验是否登录
                let verify = false;
                axios.get(`/verify`).then(({data})=>{
                    if(data == "yigou"){
                        //  没有登录
                        // 跳转登录页
                        window.location.href="login.html?returnurl="+window.location.href
                    }else{
                       // 一登陆，保存购物车
                        this.username = data
                        axios.get(`/cart/addCart?id=${this.goods.id}`).then(({data})=>{
                            if(data.code==200){
                                alert("添加成功");
                                window.location.href="cart.html"
                            }else{
                                alert("添加失败，请刷新页面重新添加或联系管理员");
                            }
                        }).catch(()=>{
                            alert("系统异常，请联系管理员");
                        })
                    }
                })
            },
            logout(){
                axios.get(`/logout`).then(()=>{
                    window.location.reload()
                });
            }
        }
    })
</script>
</html>